Vue.component('xcform_control_input_number', {
  template: '<el-form-item \
                  :class="value.fieldjsonObj.xcform_prop_required.value?\'required\':\'\'"\
                  :prop="value.fieldcode" \
                  :rules="control.rules"\
                  :label="value.fieldtitle"> \
                  <el-input-number v-model="value.value"\
                      :placeholder="value.fieldjsonObj.xcform_base_placeholder.value" \
                      :precision="parseInt(value.fieldjsonObj.xcform_base_property_input_number.floatnum)" \
                      :max="value.fieldjsonObj.xcform_prop_numberrange.value?parseInt(value.fieldjsonObj.xcform_prop_numberrange.max):Infinity" \
                      :min="value.fieldjsonObj.xcform_prop_numberrange.value?parseInt(value.fieldjsonObj.xcform_prop_numberrange.min):-Infinity" \
                      :disabled="control.disabled"></el-input-number> \
                </el-form-item>',
  props: {
    value: {
      type: Object,
    },
    disabled: {
      type: Boolean,
    },
    fieldfulljson: {
      type: Array,
    },
    xcform_id: {
      type: Number,
    }
  },
  data() {
    var validateFunction = (rule, value, callback) => {
      var that = this;
      that.value.value = (that.value.value) ? that.value.value : "";

      if (that.value.fieldjsonObj.xcform_prop_required.value) {
        if (that.value.value.length == 0) {
          return callback(new Error('不能为空'));
        }
      }
      return callback();

    };
    return {
      control: {
        disabled: false,
        rules: [{
          validator: validateFunction,
          trigger: 'blur'
        }]
      }
    };
  },
  created() {
    var that = this;
    that.control.disabled = that.disabled;
    if (that.value.fieldjsonObj.xcform_prop_readonly.value) {
      that.control.disabled = true;
    }
  },
  mounted() {
    var that = this;

  },
  methods: {}
});